/*   1:    */ package com.atomikos.icatch.imp;
/*   2:    */ 
/*   3:    */ import com.atomikos.icatch.Extent;
/*   4:    */ import com.atomikos.icatch.Participant;
/*   5:    */ import com.atomikos.icatch.SysException;
/*   6:    */ import java.util.Dictionary;
/*   7:    */ import java.util.Enumeration;
/*   8:    */ import java.util.Hashtable;
/*   9:    */ import java.util.Stack;
/*  10:    */ 
/*  11:    */ public class ExtentImp
/*  12:    */   implements Extent
/*  13:    */ {
/*  14:    */   private static final long serialVersionUID = -1010453448007350422L;
/*  15: 50 */   private Hashtable participants_ = null;
/*  16: 51 */   private boolean queried_ = false;
/*  17:    */   private Stack directs_;
/*  18:    */   
/*  19:    */   public ExtentImp()
/*  20:    */   {
/*  21: 58 */     this.participants_ = new Hashtable();
/*  22: 59 */     this.directs_ = new Stack();
/*  23:    */   }
/*  24:    */   
/*  25:    */   public ExtentImp(Hashtable participants, Stack directs)
/*  26:    */   {
/*  27: 64 */     this.participants_ = ((Hashtable)participants.clone());
/*  28: 65 */     this.directs_ = ((Stack)directs.clone());
/*  29:    */   }
/*  30:    */   
/*  31:    */   public void addRemoteParticipants(Dictionary participants)
/*  32:    */     throws IllegalStateException, SysException
/*  33:    */   {
/*  34: 71 */     if (participants == null) {
/*  35: 72 */       return;
/*  36:    */     }
/*  37: 73 */     Enumeration enumm = participants.keys();
/*  38: 74 */     while (enumm.hasMoreElements())
/*  39:    */     {
/*  40: 75 */       String participant = (String)enumm.nextElement();
/*  41: 76 */       Integer count = (Integer)this.participants_.get(participant);
/*  42: 77 */       if (count == null) {
/*  43: 78 */         count = new Integer(0);
/*  44:    */       }
/*  45: 80 */       Integer cnt = (Integer)participants.get(participant);
/*  46: 81 */       count = new Integer(count.intValue() + cnt.intValue());
/*  47:    */       
/*  48: 83 */       this.participants_.put(participant, count);
/*  49:    */     }
/*  50:    */   }
/*  51:    */   
/*  52:    */   public Hashtable getRemoteParticipants()
/*  53:    */   {
/*  54:102 */     this.queried_ = true;
/*  55:103 */     return (Hashtable)this.participants_.clone();
/*  56:    */   }
/*  57:    */   
/*  58:    */   public Stack getParticipants()
/*  59:    */   {
/*  60:112 */     this.queried_ = true;
/*  61:113 */     return (Stack)this.directs_.clone();
/*  62:    */   }
/*  63:    */   
/*  64:    */   public synchronized void add(Participant participant, int count)
/*  65:    */     throws SysException, IllegalStateException
/*  66:    */   {
/*  67:123 */     Hashtable table = new Hashtable();
/*  68:124 */     table.put(participant.getURI(), new Integer(count));
/*  69:125 */     addRemoteParticipants(table);
/*  70:126 */     this.directs_.push(participant);
/*  71:    */   }
/*  72:    */   
/*  73:    */   public synchronized void add(Extent extent)
/*  74:    */     throws IllegalStateException, SysException
/*  75:    */   {
/*  76:137 */     if (this.queried_) {
/*  77:138 */       throw new IllegalStateException("Adding extent no longer allowed");
/*  78:    */     }
/*  79:139 */     addRemoteParticipants(extent.getRemoteParticipants());
/*  80:140 */     Enumeration enumm = extent.getParticipants().elements();
/*  81:141 */     while (enumm.hasMoreElements())
/*  82:    */     {
/*  83:142 */       Participant part = (Participant)enumm.nextElement();
/*  84:143 */       this.directs_.push(part);
/*  85:    */     }
/*  86:    */   }
/*  87:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions\3.7.0\transactions-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.imp.ExtentImp
 * JD-Core Version:    0.7.0.1
 */